package com.xiaoyu.lanling.feature.chat.model.message

import com.xiaoyu.base.image.ImageLoadInfo
import com.xiaoyu.im.datamodel.AppMessage
import com.xiaoyu.lanling.feature.chat.viewholder.ChatViewHolderManager
import com.xiaoyu.lanling.media.image.ImageLoadParam

class ChatMessageReceiveImageItem(message: AppMessage) : ChatMessageReceiveBaseItem(message) {
    val imageUrl: String = message.payload.url
    val imageLoadInfo = ImageLoadInfo(imageUrl)
    val width: Int = ChatImageSizer.getImageWidth(imageLoadInfo)
    val height: Int = ChatImageSizer.getImageHeight(imageLoadInfo)
    val imageLoadParam: ImageLoadParam = ImageLoadParam.newBuilder().setWidth(width).setHeight(height).setCornersRadiusInDP(8f).setUrl(imageUrl).build()
    val rewardInfo = RewardInfo(attrs.optJson("rewardInfo"))

    override val childrenViewType: Int
        get() = ChatViewHolderManager.TYPE_RECEIVE_IMAGE
}